package com.fresh.task;

import java.util.concurrent.TimeUnit;

import net.sf.json.JSONObject;

import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

import com.fresh.wx.utils.CommonUtil;
import com.fresh.wx.utils.WXConfig;

@Component
public class TokenTask {

	@Scheduled(cron = "0 0/30 * * * ?")
    public void run() {
      
		JSONObject jsonObject = CommonUtil.httpsRequest(WXConfig.GETACCESS, "GET", null);
		System.out.println("-------------------------    "+jsonObject);
		if(jsonObject!=null){
			WXConfig.TOKEN =  jsonObject.getString("access_token");
			
			System.out.println(" 微信API 获取Token 值   ：         "+WXConfig.TOKEN );
		}
		
    }
}
